package array;

public class SortMaopao {
	public static void main(String[] args) {
		int arr[]={15,23,12,7,9,21};
		System.out.println("sorted before:");
		print(arr);
		for(int i=0;i<arr.length-1;i++)
			for(int j=0;j<arr.length-1-i;j++){
				int temp;
				if(arr[j]>arr[j+1]){
					temp=arr[j];
					arr[j]=arr[j+1];
					arr[j+1]=temp;
				}
			}
		System.out.println();
		System.out.println("sorted after:");
		print(arr);
		
	}
    static void print(int[]arr){
    	for(int x:arr)
    		System.out.printf("%4d",x);
    }

}
